//
//  maoyixqViewController.m
//  PASystem
//
//  Created by michael on 16/8/17.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "maoyixqViewController.h"
#import "mocha.h"
#import "maochaxqTableViewCell.h"
@interface maoyixqViewController ()

@end

@implementation maoyixqViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  self.view.backgroundColor = [UIColor whiteColor];
    [self loaddata];
    self.title = _string;}
- (void)loaddata{

    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSString * pwdId = [[NSUserDefaults standardUserDefaults]objectForKey:@"pwdId"];
    NSString * userHumber = [[NSUserDefaults standardUserDefaults]objectForKey:@"userHumber"];
    
 NSString *json =[NSString stringWithFormat: @"{'action':%@,'service': %@, 'userName':'%@','password':'%@', 'vaueJson':'{userid :%@,id:%@}'}",_action,_service,userId,pwdId,userHumber,_id];
     NSArray * array = @[@{@"arg0":json}];
    [HttpTools requestWithURL:BaseURL arrays:array method:Basemethod success:^(id JSON) {

       NSDictionary *updic = JSON[@"reason"];
       _dic1 = updic[@"attrs"];
       NSLog(@"%@",_dic1);
       _dataArray = [NSMutableArray array];
        NSArray *downarray = JSON[@"InvolvedEnterprises"];
for (NSDictionary *dic in downarray) {
    mocamodel *model = [mocamodel mj_objectWithKeyValues:dic[@"attrs"]];
    [_dataArray addObject:model];
}

       
       [self initview];
 
    } failure:^(NSError *error) {
        
    }];



}
- (void)initview{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, (KScreenHeight-64-46)/2)];
UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
view.backgroundColor = myColor;

[self.view addSubview:view];
 mocha *qiye = [[mocha alloc]initWithFrame:CGRectMake(10, 10, KScreenWidth-20, (KScreenHeight-64-46)/2-20)];
qiye.dic = _dic1;
//qiye.backgroundColor = [UIColor redColor];
[view addSubview:qiye];
  float itemHeight = (KScreenHeight-46-64) /5;

 UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, view.bottom, KScreenWidth, itemHeight*1/4)];
    view1.backgroundColor = [UIColor whiteColor];
    UIView *viewcolor = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, view1.height)];
    viewcolor.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"图标3"]];
    [view1 addSubview:viewcolor];
     UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(viewcolor.right, viewcolor.top+5, 200, view1.height-5)];
    label.text = @"涉案企业 :";
    [view1 addSubview:label];
[self.view addSubview:view1];
_tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, view1.bottom, KScreenWidth, (KScreenHeight-64-46)/2) style:UITableViewStylePlain];


_tableview.dataSource = self;
_tableview.delegate = self;
_tableview.bounces = NO;
[self.view addSubview:_tableview];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  _dataArray.count;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark UITableView dataScource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
 static NSString *CellIdentifier = @"Cell111111";  

    maochaxqTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell==nil) {  
        cell=[[maochaxqTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    mocamodel *model = _dataArray [indexPath.row];
    cell.model = model;
//cell.action = _action;
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
